<?php

namespace app\admin\model\yiliao;

use think\Model;


class Pbholiday extends Model
{

    

    

    // 表名
    protected $name = 'yiliao_pbholiday';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'shangdata_text',
        'xiadata_text',
        'status_text'
    ];
    

    
    public function getShangdataList()
    {
        return ['1' => __('Shangdata 1'), '0' => __('Shangdata 0')];
    }

    public function getXiadataList()
    {
        return ['1' => __('Xiadata 1'), '0' => __('Xiadata 0')];
    }

    public function getStatusList()
    {
        return ['1' => __('Status 1'), '0' => __('Status 0')];
    }


    public function getShangdataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['shangdata']) ? $data['shangdata'] : '');
        $list = $this->getShangdataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getXiadataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['xiadata']) ? $data['xiadata'] : '');
        $list = $this->getXiadataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

	public function doctor(){
		return $this->belongsTo('Doctor', 'yiliao_doctor_id', 'id', [], 'LEFT')->setEagerlyType(0);
	}


}
